import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';

import '../../model/food/send_food_model.dart';

class SendFoodTableViewModel extends BaseListViewModel<ISendFoodTableData> {
  final String? titleName;
  final String? buildingId;
  final String? floorId;

  var model = SendFoodModel();

  SendFoodTableViewModel(BuildContext context,
      {this.titleName, this.buildingId, this.floorId})
      : super(context);

  @override
  Future<List<ISendFoodTableData>> requestListData() async {
    var date = DateTime.now().toDateStr(["yyyy","-","mm","-","dd"]);
    var list = await model.getSendFood(buildingId, floorId, date,start: page,row: pageLength);
    return list;
  }

  var titles = ["房间", "姓名", "早餐", "中餐", "晚餐"];

  Widget contentView() {
    return Row(
      children: titles
          .map((e) => CommonText(e)
              .addToContainer(
        alignment: Alignment.center,
                  margin: EdgeInsets.all(2),
                  decoration: BoxDecoration(
                      color: Colors.white, borderRadius: 3.borderRadius),
                  padding: EdgeInsets.symmetric(horizontal: 10, vertical: 16))
              .setWeight(1))
          .toList(),
    ).addToContainer(margin: EdgeInsets.only(left: 2,right: 2,top: 2));
  }


  Widget itemContent(int index){
    var item = listItems[index];
    var list = [
      "${item.iRoomName}",
      "${item.iOldName}",
      "${item.iBreakfast}",
      "${item.iLaunch}",
      "${item.iDinner}",
    ];
    return IntrinsicHeight(

      child: Row(
        children: list
            .map((e) => CommonText(e,height: 1.5)
            .addToContainer(
            alignment: Alignment.center,
            margin: EdgeInsets.all(2),
            decoration: BoxDecoration(
                color: Colors.white, borderRadius: 3.borderRadius),
            padding: EdgeInsets.symmetric(horizontal: 10, vertical: 16))
            .setWeight(1))
            .toList(),
      ),
    ).addToContainer(margin: EdgeInsets.only(left: 2,right: 2));
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

}
